#pragma once

#include "opencv2/opencv.hpp"
#include "cvblob.h"

using namespace cv;

/// \class FingerTracker
/// \brief Detect and track hand and fingertips
class FingerTracker
{
public:
	FingerTracker();
	~FingerTracker();

	void					Step(const Mat &input, Mat *outputBinary, Mat *outputColor);

	void					SetParam(int k,int cannyThres,int chainThres);
	void					set_minDist(int dist);

private:
	cvb::CvTracks			mHandTracks;
	cvb::CvTracks			mFingerTracks;

	int						canny_thresh;
	int						chain_thresh;
	int						K;
	vector<Point>			tip;
	vector<vector<Point>>	chains;
	vector<Vec4i>			hierarchy;
	int						minDist;

	//detect methods
	void					findHand(const Mat &input, Mat *output);
	void					findFingertips(const Mat &input, Mat *output);
	void				    findStrings(const Mat &input,Mat *output);

	void					cluster();

	//params settings
	void					k_Curvature(int i);
	void					set_K(int k);
	void					set_Canny_thresh( int thresh);
	void					set_Chain_thresh( int thresh);
};